<template>
	<div>
		<div id="slider" class="mui-slider mui-fullscreen">
				<div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
					<div class="mui-scroll">
						<span :class="['mui-control-item',item.id == 0? 'mui-active' : '']" data-wid="tab-top-subpage-1.html"  v-for="item in list" @tap="getImg(item.id)" :key = 'item.id'>
							{{item.title}}
						</span>
						
					</div>
				</div>

			</div>
			<ul class="photo-img">
				<RouterLink tag = 'li' :to="'/home/Analysis/details/'+imgs.id" v-for="imgs in listImg" :key = "imgs.id">
					<img v-lazy = "imgs.img_url" />
					<div class="cont">
						<p>{{imgs.title}}</p>
						<p>{{imgs.zhaiyao}}</p>
					</div>
				</RouterLink>
				
			</ul>
	</div>
</template>

<script>
	import {Toast} from 'mint-ui'
	import mui from '../../libs/mui-master/dist/js/mui.min.js'	
	export default{
		data(){
			return{
				list:[],
				listImg:[]
			}
		},
		created(){
			this.getTitle(),
			this.getImg(0)
		},
		mounted(){
			mui('.mui-scroll-wrapper').scroll({
				deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
			})
			
		},	
		methods:{
			getTitle(){
				this.$http.get('api/getimgcategory').then((resolve)=>{
					if(resolve.body.status == 0){
						this.list = resolve.body.message;
						this.list.unshift({id:0,title:'全部'})
					}
				},(reject)=>{
					Toast('网络错误!')
				})
			},
			getImg(indexId){
				this.$http.get('api/getimages/'+indexId).then((resolve)=>{
					if(resolve.body.status == 0){
						this.listImg = resolve.body.message;
					}
				},(reject)=>{
					Toast('网络错误!')
				})
			}
		}
	}
</script>

<style scoped lang="less">
	.mui-fullscreen{
		position: static;
	}
	img[lazy = "loading"]{
		width: 40px;
		height: 300px;
		margin: auto;
	}
	.photo-img{
		padding: 0;
		margin: 0 0 4em 0;
		text-align: center;
		padding: 0 10px;
	
		li{
			width: 100%;
			list-style: none;				
			margin-bottom:10px;
			box-shadow: 2px 3px 2px #888888;
			background:#999999;
			position: relative;
		}
		.cont{			
			position: absolute;
			bottom: 0px;
			text-align: left;
			background: black;
			background-color: rgba(0, 0, 0, 0.4);
			max-height: 90px;
			p:nth-of-type(1){
				color: white;
				font-size: 14px;
			}
			p:nth-of-type(2){
				color: white;
				font-size: 13px;
			}
		}
		
	}
</style>
